<!--
 * @Author: JiraiyaChen 979526234@qq.com
 * @Date: 2025-03-17 16:33:32
 * @LastEditors: JiraiyaChen 979526234@qq.com
 * @LastEditTime: 2025-03-28 16:03:08
 * @Description: 导入文件 弹框
-->

<template>
  <ClDialog v-bind="$attrs" :title="getTitle" width="1390px">
    <ClBar :loading="loaded">
      <ClUpload :init-upload-list="initUploadList" :supplier-id="props.info.id" :project-id="projectInfo.id" />
    </ClBar>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="emit('atClose')">取消</el-button>
        <el-button type="primary" @click="onSure">确定</el-button>
      </span>
    </template>
  </ClDialog>
</template>

<script setup lang="ts">
import { computed, ref } from 'vue'
import { supplierFileInfoList } from '@/api/electronic-bid-file'
import { useProjectInfoStore } from '@/store/projectInfo'
const { projectInfo } = useProjectInfoStore()
const onSure = () => {
  emit('atClose', 'refresh-table')
}
onMounted(() => {
  getInitUploadList()
})
const loaded = ref(false)
const initUploadList = ref<any[]>([])
const getInitUploadList = async () => {
  try {
    loaded.value = false
    const { rows }: any = await supplierFileInfoList({ supplierId: props.info.id })
    initUploadList.value = rows
    loaded.value = true
  } catch (error) {
    loaded.value = true
    console.log('🐷 🐽 getInitUploadList 🐽 error👉👉👉', error)
  }
}
const getTitle = computed(() => {
  return props.type
})

interface infoType {
  [props: string]: any
}
const props = defineProps<{ info: infoType; type: string }>()

const emit = defineEmits<{
  (e: 'atClose', str?: string | undefined): void
}>()
</script>

<style scoped lang="scss"></style>
